package org.alex.farouq.exam.test;

import java.io.FileWriter;

import java.io.IOException;
import java.io.PrintWriter;

import org.alex.farouq.exam.model.question.Question;


public class ExamWriter {
	private String filePath;
	
	public ExamWriter(String filePath){
		setFilePath(filePath);
	}
	
	public boolean Write(Question question){
		try {
		      FileWriter outFile = new FileWriter(getFilePath());
		      PrintWriter out = new PrintWriter(outFile);
		      out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
		      out.println("<!DOCTYPE EXAMDB SYSTEM \"EXAMDB.dtd\">");
		      out.println(question);
		      out.close();
		 } catch (IOException e){
		      e.printStackTrace();
		      return false;
		 }
		return true;
	}
	
	public String getFilePath() {
		return filePath;
	}
	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}
}
